package tom.spring.cloud.stream.receiver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

/**
 * Sink是spring的消息流输入接口绑定的定义<br>
 * 输出{@link org.springframework.cloud.stream.messaging.Source}。
 * EnableBinding会自动注入包含的流定义bean，用于发布和订阅, 注解内包含Configuration注解，被注解的相当于配置类。
 * 包含的输入输出流定义为接口定义，输出(发布)返回类型必须为MessageChannel, 输入(订阅)返回必须为SubscribableChannel.
 * @author ZHUFEIFEI
 */
@Slf4j
@EnableBinding({Sink.class})
public class SinkReceiver {

    /**
     * 绑定application.yml中配置的destination，接收消息
     * @param payload
     */
    @StreamListener(Sink.INPUT)
    public void receive(Object payload) {
        log.info("receive : {}", payload);
    }
}
